<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
</head>
<body>
<div class="layui-container" style="width: 100%">
    <div class="layui-row"></div>
    <div class="layui-row">
        <form class="layui-form" id="form1" lay-filter="form1">
            <div class="layui-form-item">
                <input type="password" id="password1" name="password1" required placeholder="请输入密码"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <input type="password" id="password2" name="password2" required placeholder="请确认密码"
                       class="layui-input">
            </div>
            <div class="layui-form-item" style="text-align: center;">
                <button type="button" class="layui-btn" style="margin: 0 auto;width: 129px;"
                        onclick="change()">确定
                </button>
            </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript" src="../../static/layui/layui.all.js"></script>
<script type="text/javascript" src="../../static/config.js"></script>
<script type="text/javascript">
    const $ = layui.$;
    const layer = layui.layer;
    const form = layui.form;

    function change() {
        const p1 = $("#password1");
        const p2 = $("#password2");
        if (p1.val() !== p2.val()) {
            layer.msg("两次输入的密码不一致！");
            return;
        }
        $.post({
            url: baseUrl + "/hospital-doctor/doctor/updatePassword",
            headers: {
                "x-token": localStorage.getItem("x-token")
            },
            data: form.val("form1")
        });
        parent.layer.msg("修改成功！");
        localStorage.removeItem("x-token");
        parent.parent.location.reload();
    }
</script>
</html>